home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
commercial
/
sunrize
/
psound_3.1
/
public_domain
/
noisy
/
noisy_lib.doc
< prev
next >
Wrap
Text File
|
1994-11-17
|
6KB
|
178 lines
Included on Perfect Sound master disk with Permission from the Author
noisy.library docs
Copyright © 1990, W. W. Howe
All Rights Reserved
"Noisy" is an Amiga runtime library designed to ease the task of
creating and playing sampled and other sounds from any program. Written
entirely in 68000 assembler, this small (2300 byte) library handles the
tasks of parsing 8SVX (IFF) sound files, managing memory allocations
and interfacing to the audio.device. All these functions are accomplished
through the following calls:
* Key = LoadSound(Name, Flags)
This function takes a filename and attempts to load the file into
a chip ram buffer for subsequent playing. If successful, A 'Key' necessary
for other library calls for that sound file is returned. Any problem, such
as an absent file, will return a invalid Key of 0.
Although the loader understands and accepts IFF sound files, any file
may be loaded via this call. If it isn't an IFF sound file, it is loaded
as if it was a raw sound file. So you can play anything, even your
startup-sequence.
IFF files use a Period computed from the samples_per_second within
the file, and the volume specified. Raw and other non-IFF files have a
default of 64 (full) for the volume and 357 [10,000 samples_per_second]
for the period.
Sounds loaded with this call may be played again and again until
removed with the UnLoadSound() call.
The 'Flags' parameter is reserved for possible future enhancements, it
should currently always be set to 0.
* UnLoadSound(Key)
This call frees the memory and facilities allocated for a particular
sound represented by the 'Key' returned from a call to LoadSound(). Once
called, the key is no longer a valid key for future calls.
* Key = CreateSound(mem_ptr, Length, Flags)
The CreateSound() function is designed to add a sound to the internal
list used by PlaySound() from a memory area rather than from a disk file.
The volume and period are set to the same defaults as raw sound files,
and a Key is returned.
This function allocates chip memory and copies the original area, making
it unnecessary to utilize chip memory to create special waves.
* DeleteSound(Key)
This call frees the memory and facilities allocated for a particular
sound represented by the 'Key' returned from a call to CreateSound(). Once
called, the key is no longer a valid key for future calls.
* Err = PlaySound(Key)
This is the real business end of the whole library. You call this with a
valid Key obtained from one of the previous calls and either have the
sound play or an non-zero error value is returned.
* Old = SetPeriod(Key, Period)
This call changes the Period for a particular sound and returns the old
period value. The Period is a number computed by dividing 3579545 by the
samples per second. So 10000 samples_per_second equals a Period of 357.
The range is limited to 148 to 65535 for the Period value. An invalid
value will leave the current value unchanged and will return -1.
* Old = SetVolume(Key, Period)
This call changes the Volume for a particular sound and returns the old
Volume value. Range is from 0 (off) to 64 (full Volume). An invalid
value will leave the current value unchanged and will return -1.
* Old = SetCycles(Key, Period)
This call changes the Cycles for a particular sound and returns the old
Cycles value. By default, a cycle of 1 is setup for each sound, and it will
be played once. By using this function, you can make a sound play more than
once per call from PlaySound(). Valid counts are in the range of 1 to
65535, and zero, which plays 65536 times. An invalid value will leave the
current value unchanged and will return -1.
* PanicRecovery()
This is a dangerous call. It walks the internal lists and frees all
the resources allocated. The danger is that a program may be holding
some keys and a library vector, and be expecting to use the library and
play sounds, and this call makes it possible for the library to be
expunged (this call does not expunge the library itself) thus, in effect,
pulling the rug out from under the program.
On the other hand, this call makes it possible to recover resources
left open by a program that misbehaved, i.e. Loaded some sounds and
then for whatever reason exited without calling the UnLoadSound() function
for one or more.
The best use is to make a small program that opens the library, calls
this function, and then closes the library and exits. Run this new
program only when you need to clean up after an errant program. There is
a small program (FreeLibDanger) distributed in this package that does just
that. Use it wisely, otherwise, please don't complain about it.
INSTALLATION:
Copy noisy.library and noisy.bmap to the LIBS: directory. A smaple
basic program using the library, LibTest.Bas has been included. It requires
the file hal.snd (also included) be in the current directory along with
the program.
MISCELLANEOUS:
For some reason I have been unable to ascertain, the library crashes
whenever a fifth attenpt to allocate a sound channel (there are only
four sound channels in the Amiga) is performed. It appears to be in the
OpenDevice() call, but whether it is due to my programming or a problem
in the OS remains to be determined.
To work around this, I have placed code to prevent more than 4 sounds
to be played via the library simultaneously. A fifth call to PlaySound()
before any of the previous four have finished will simply return with an
error code.
ERROR VALUES:
Returns from PlaySound():
100 = Library Initialization problem (No DOS)
99 = Memory shortage
98 = Invalid key passed
97 = No audio channels available
-11 = Allocation failed.
<* Wesley Howe *>